﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Remote_server
{
    /// <summary>
    /// This class will handle any incoming commands
    /// and send appropriate error messages when they are
    /// note well formed
    /// </summary>
    public static class CommandHandler
    {
        /// <summary>
        /// A large switch that handles the Command attached
        /// to the event arguments
        /// </summary>
        /// <param name="e">The event arguments passed together
        /// with the bubbling event</param>
        public static void HandleCommand(CommandReceivedEventArgs e)
        {
            //Handled is set to false if reaching the default-branch
            e.Handled = true;
            switch (e.Command.Name)
            {
                case "MUTE":
                    MediaHandler.Mute();
                    break;
                case "VOLDOWN":
                    MediaHandler.VolumeDown(5);
                    break;
                case "VOLUP":
                    MediaHandler.VolumeUp(5);
                    break;
                case "NEXT":
                    MediaHandler.PlayNext();
                    break;
                case "PREV":
                    MediaHandler.PlayPrev();
                    break;
                case "PLAY":
                    MediaHandler.Play();
                    break;
                case "PAUSE":
                    MediaHandler.Pause();
                    break;
                case "LOGOUT":
                    break;

                default:
                    e.Error = "Command not accepted";
                    e.Handled = false;
                    break;
            }
        }
    }
}
